#if !defined( NEWHAMPSHIRE_TREEMAKER_H)
#define  NEWHAMPSHIRE_TREEMAKER_H
#include <sstream>
#include <string>
//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

//		newhampshire_tree_maker

//________________________________________________________________________________________
//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
struct newhampshire_tree_maker
{
	newhampshire_tree_maker(bool i = false) : ignore_branch_lengths(i){}
	bool ignore_branch_lengths;
	std::string str;
	void add_leaf(const std::string& name, unsigned);
	void add_internal_node();
	void set_branch_len(double len);
	void reparent_to_grandparent();
	void finish();
	void add_sibling();
};
void newhampshire_tree_maker::add_leaf(const std::string& name, unsigned)
{
//	cerr << "Add leaf " << name << "\n";
	str += name;
}
void newhampshire_tree_maker::add_internal_node()
{
//	cerr << "Add internal node \n";
	str += '(';
}
void newhampshire_tree_maker::set_branch_len(double len)
{
//	cerr << "set branch len " << len << "\n";
	if (ignore_branch_lengths)
		return;
	std::ostringstream os;
	os << len;
	str += ':' + os.str();
}
void newhampshire_tree_maker::reparent_to_grandparent()
{
//	cerr << "Reparent\n";
	str += ')';
}
void newhampshire_tree_maker::finish()
{
//	cerr << "Finish\n";
	str += ';';
}
void newhampshire_tree_maker::add_sibling()
{
	str += ',';
}

//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888



#endif
